package Servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/courseRemove")
public class courseRemove extends HttpServlet {
	private static final long serialVersionUID = 1L;

    public courseRemove() {
        super();
        // TODO Auto-generated constructor stub
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		
		String name = (String) request.getSession().getAttribute("insname");
		String id = (String) request.getSession().getAttribute("id");
		String[] dropped = request.getParameterValues("course");
		System.out.print("Unassigning Courses - ");
		System.out.println(name+" "+id);
		try {
			for(String s : dropped)
				System.out.println(s);	
		}
		catch(NullPointerException e)
		{
			PrintWriter out = response.getWriter();
			out.println("<html>");
			out.println("<style type='text/css'> body{ text-align: justify;background-color:orange; font-family: Cambria} h1{text-align: center; color: black;font-family: Cambria;} form{font-family:Cambria;}</style>");
			out.println("<body>");
			out.println("<h1>Error Page</h1>");
			out.println("<br><p>Whoops, you got us!!!</p><br>");
			out.println("Hit this --->");
			out.println("<input Type='button' VALUE='Back' onClick='history.go(-1);return true;'>");
			out.println("<script type=\'text/javascript\'>");
			out.println("alert('Error : No selections made.');");
			out.println("</script>");
			out.println("</body>");
			out.println("</html>");
		}
	}

}
